package com.cityfood.common.utils;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Transformer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class MyStringUtils {

    public static List<Integer> GetIntList(String ids){
        List<String> idsStringList = Arrays.asList(ids.split(","));
        List<Integer> idsList = new ArrayList<>();
        CollectionUtils.collect(idsStringList, new Transformer() {
            @Override
            public Object transform(Object o) {
                return Integer.valueOf(o.toString());
            }
        }, idsList);
        return idsList;
    }
    
    public static String getSpecsStr(String specJsonStr){
    	@SuppressWarnings("rawtypes")
		Map map = JsonUtils.jsonToMap(specJsonStr);
    	String specsStr = "";
        for (Object str: map.values()) {
            specsStr += String.format("%s ", str);
        }
        return  specsStr.trim();
    }

}
